Method and device for pulse encoding, method and device for pulse decoding

ABSTRACT

The present invention discloses a method and a device for pulse encoding, and a method and a device for pulse decoding. The method for pulse encoding includes: calculating an index value of an input pulse; selecting an adjustment threshold value according to the number of pulses, and comparing the index value of the pulse with the adjustment threshold value; if the index value is smaller than the adjustment threshold value, adopting the first number of encoding bits to encode the index value, if the index value is not smaller than the adjustment threshold value, adopting the second number of encoding bits to encode the index value plus an offset value, where the first number is smaller than the second number, the first number and the second number are both positive integers, and the offset value is greater than or equal to the adjustment threshold value.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of U.S. application Ser. No.13/325,993, filed on Dec. 14, 2011, which is a continuation ofInternational Application No. PCT/CN2010/073651, filed on Jun. 8, 2010,which claims priority to Chinese Patent Application No. 200910150637.8,filed on Jun. 19, 2009, the afore-mentioned patent applications arehereby incorporated by reference in their entireties.

TECHNICAL FIELD

The present invention relates to encoding and decoding technologies, andin particular, to a method and a device for pulse encoding, and a methodand a device for pulse decoding.

BACKGROUND

In the field of voice encoding, a voice encoder based on a Code ExcitedLinear Prediction (CELP) encoding model is the most widely used.Compared with voice encoders of other types, the voice encoder canobtain good voice quality in the case of a very low bit rate, and itsperformance is still outstanding in the case of a high bit rate. In theCELP model, as simulation of an excitation signal, an adaptive codebookand a fixed codebook play a very important role. The role of an adaptivefilter is to remove long-term correlation from a voice residual signal.After the long-term correlation from the voice residual signal isremoved, the voice residual signal becomes similar to a white noise.Therefore, it is difficult to effectively quantize a target signal ofthe fixed codebook. Currently, a method to deal with the fixed codebookis to replace the fixed codebook with an algebraic codebook.

In a voice encoder, location and symbol information about all pulses oneach track is obtained through an algebraic codebook search. Toeffectively transmit the location and symbol information about allpulses on each track to a decoder end, the location and symbolinformation about these pulses must be processed properly. Theprocessing must ensure that no location or symbol information about anypulse is lost, that is to say, the decoder end can uniquely recover thelocation and symbol information about all pulses. Meanwhile, to reducethe bit rate as much as possible, the processing method must ensure thatthe location and symbol information about the pulses are encoded byusing minimum bits. The number of bits used to encode the location andsymbol information about all pulses on each track in a theoretical casemay be obtained through collecting statistics about permutations andcombinations of all pulse locations on the same track. The number ofbits used to encode the number of permutations and combinations of allpulse locations on the same track is a theoretical lower limit. Whencategorizing and orderly encoding the number of permutations andcombinations of all pulse locations on the same track, the requirednumber of bits may reach the theoretical lower limit if the theoreticallower limit is an integer, and may be equal to the integral part of thetheoretical lower limit plus one if the theoretical lower limit is adecimal.

Assume that n pulses exist on a same track, location and symbolinformation about the n pulses are respectively obtained through analgebraic codebook search algorithm, and multiple pulses may exist on asame location on the same track. In this case, if the multiple pulses onthe same location are encoded respectively, a lot of pulses were wasted.From the perspective of permutations and combinations, a p₀, and a p₁ onthe same location and a p₁ and a p₀ on the same location belong to thesame case. Therefore, to save bits as much as possible and avoidencoding a same case multiple times, collect statistics about locationswith a pulse (regarding a location with multiple pulses as one pulselocation), output information about pulse locations, information aboutthe number of pulses, and information about corresponding pulse symbols,and take the pulse locations into consideration in terms of category. Ifn pulses exist on a same track, the number of pulse locations may becategorized through collecting statistics about the pulse locations.Assume that the number of pulse locations is m. It may be predicted thatthe value range of m is 1≦m≦n For each specific value of m, calculatethe number of permutations and combinations of a pulse statisticalfunction (assuming that the total number of permutations andcombinations is W), divide data within a specific range into w segments,and the corresponding number of permutations and combinations W isrelated to the total number of pulses on a track.

For the convenience of encoding the foregoing categories in an orderlymanner, the foregoing categories are effectively combined here. Anexisting combination method is described as follows: 1. Calculate thenumber of all the foregoing permutations and combinations, calculate theultimately required number of bits BIT, and divide the bit stream intoseveral segments. Each segment represents a category. 2. Categories areclassified according to the value of m. Generally, the number ofcategories is n. A first category indicates that n pulse locationspersist after pulse locations are combined; a second category indicatesthat n−1 pulse locations persist after pulse locations are combined; therest may be deduced by analogy. An n^(th) category indicates that onepulse location persists after pulse locations are combined. Eachcategory exists only in a closed range, such as [0x100000, 0x17FFFF]. 3.For a certain category, several bits (the number of bits is determinedby the total number of permutations and combinations of pulse locationfunctions) are taken out to represent a sub-category.

After the categorization processing according to the foregoing threesteps, sequence the categories. The categories are sequenced in manyways, and are sequenced according to the number of pulse locations indescending order here. Finally, put each category in a different segmentto finally form an ultimate index value. After receiving the ultimateindex value, the decoder end performs decoding according to theforegoing sequencing order of each category, sub-category, and thenumber of combinations to obtain the location and symbol informationabout each pulse. That is, the entire encoding and decoding process iscompleted.

In the research of the prior art, the inventor finds that: Although theintegral value of the theoretical number of bits can be used forencoding by adopting the foregoing technical solution, in the case thatthe number of pulses on each track is fixed, the number of bits used forany pulse combination is fixed. For example, 6 pulses exist on a track,and the theoretical value of encoding bits is 20.5637. Therefore, 21bits need to be used for encoding. 21 bits can indicate a range from 0to 2^21−1, while the index of 6 pulses ranges from 0 to 1549823. 547328numerical values exist from 1549824 to 2^21−1. Therefore, about 26.1%space is wasted, and therefore, encoding bits are wasted, which resultsin low encoding efficiency.

SUMMARY

Embodiments of the present invention provide a method and a device forpulse encoding, and a method and a device for pulse decoding, which cansave encoding bits and improve encoding efficiency.

An embodiment of the present invention provides a method for pulseencoding, where the method includes:

calculating an index value of an input pulse;

selecting an adjustment threshold value according to the number ofpulses, and comparing the index value of the pulse with the adjustmentthreshold value; and

if the index value is smaller than the adjustment threshold value,adopting the first number of encoding bits to encode the index value, ifthe index value is not smaller than the adjustment threshold value,adopting the second number of encoding bits to encode the index valueplus an offset value, where the first number is smaller than the secondnumber, the first number and the second number are both positiveintegers, and the offset value is greater than or equal to theadjustment threshold value.

An embodiment of the present invention further provides a method forpulse decoding, where the method includes:

demultiplexing an encoding code stream and extracting the first numberof encoding bits from the demultiplexed encoding code stream;

if a decoded value of the first number of encoding bits is smaller thanan adjustment threshold value, outputting the decoded value of the firstnumber of encoding bits; and

if the decoded value of the first number of encoding bits is greaterthan or equal to the adjustment threshold value, decoding the secondnumber of encoding bits, where the second number of encoding bits isextracted from the code stream, and outputting a decoded value of thesecond number of encoding bits, where the first number is smaller thanthe second number, and the first number and the second number are bothpositive integers.

An embodiment of the present invention further provides a device forpulse encoding, where the device includes:

a calculating unit, configured to calculate an index value of an inputpulse;

a selection unit, configured to select an adjustment threshold valueaccording to the number of pulses; and

an encoding unit, configured to adopt the first number of encoding bitsto encode the index value if the index value calculated and obtained bythe calculating unit is smaller than the adjustment threshold valueselected by the selection unit, and adopt the second number of encodingbits to encode the index value plus an offset value if the index valuecalculated and obtained by the calculating unit is greater than or equalto the adjustment threshold value selected by the selection unit, wherethe first number is smaller than the second number, the first number andthe second number are both positive integers, and the offset value isgreater than or equal to the adjustment threshold value.

An embodiment of the present invention further provides a device forpulse decoding, where the device includes:

an extraction unit, configured to demultiplex an encoding code streamand extract the first number of encoding bits from the demultiplexedencoding code stream;

a decoding unit, configured to decode the first number of encoding bitsextracted by the extraction unit, and decode the second number ofencoding bits, where the second number of encoding bits is extractedfrom the code stream, if a decoded value of the first number of encodingbits is greater than or equal to the adjustment threshold value; and

an output unit, configured to output the decoded value of the firstnumber of encoding bits if the decoded value of the first number ofencoding bits decoded and obtained by the decoding unit is smaller thanthe adjustment threshold value, and output a decoded value of the secondnumber of encoding bits if the decoded value of the first number ofencoding bits decoded and obtained by the decoding unit is not smallerthe adjustment threshold value, where the first number is smaller thanthe second number, and the first number and the second number are bothpositive integers.

It can be seen from the foregoing technical solutions provided in theembodiments of the present invention that, according to the embodimentsof the present invention, the first number of encoding bits may be usedto encode the index value if the index value is smaller than theadjustment threshold value. That is, the second number of encoding bitsdoes not need to be used to encode the index value smaller than theadjustment threshold value. In this way, the encoding bits are saved,and the encoding efficiency is improved.

BRIEF DESCRIPTION OF THE DRAWINGS

To illustrate the technical solutions according to the embodiments ofthe present invention or in the prior art more clearly, accompanyingdrawings needed for describing the embodiments or the prior art arebriefly introduced below. Apparently, the accompanying drawings in thefollowing description are only some embodiments of the present inventionand persons of ordinary skill in the art may also obtained otherdrawings according to the accompanying drawings without creativeefforts.

FIG. 1 is a flow chart of an embodiment of a method for pulse encodingaccording to an embodiment of the present invention;

FIG. 2 is a schematic diagram of index encoding according to anembodiment of the present invention;

FIG. 3 is a schematic diagram of a remaining space adjustment accordingto an embodiment of the present invention;

FIG. 4 is a flow chart of an embodiment of a method for pulse decodingaccording to an embodiment of the present invention;

FIG. 5 is a structural diagram of a first embodiment of a device forpulse encoding according to an embodiment of the present invention;

FIG. 6 is a structural diagram of a second embodiment of the device forpulse encoding according to an embodiment of the present invention;

FIG. 7 is a structural diagram of a first embodiment of a device forpulse decoding according to an embodiment of the present invention; and

FIG. 8 is a structural diagram of a second embodiment of the device forpulse decoding according to an embodiment of the present invention.

DETAILED DESCRIPTION

The technical solutions in the embodiments of the present invention areclearly and fully described in the following with reference to theaccompanying drawings in the embodiments of the present invention.Obviously, the embodiments to be described are only part of rather thanall of the embodiments of the present invention. All other embodimentsobtained by persons of ordinary skill in the art based on theembodiments of the present invention without creative efforts shall fallwithin the protection scope of the present invention.

A method for pulse encoding provided in an embodiment of the presentinvention is described first. FIG. 1 describes a process of anembodiment of the method for pulse encoding, where the method includes:

101: Calculate an index value of an input pulse.

The input pulse is a pulse possessed by an input signal. The number ofpulses on a track and a location and symbol of each pulse may beobtained by searching the input signal.

Specifically, after the number of pulses is determined, a codebook spacewhere a corresponding index value is located is determined. Then, theindex value may be determined according to the location where each pulseis located and the symbol of each pulse.

102: Select an adjustment threshold value according to the number ofpulses.

After the number of pulses is determined, the codebook space where thecorresponding index value is located is determined. Accordingly, thenumber of encoding bits required to encode the codebook space is alsodetermined. For example, when 6 pulses exist on a track, 21 encodingbits are required to encode a codebook space corresponding to an indexvalue of the 6 pulses. However, the codebook space corresponding to theindex value of the 6 pulses does not occupy all the encoding spacecorresponding to the 21 encoding bits. That is, a certain remainingspace exists. In an embodiment of the present invention, the adjustmentthreshold value is smaller than or equal to the number of numericalvalues in the remaining space. Therefore, the adjustment thresholdvalues corresponding to the various numbers of pulses may be preset.

The set number of adjustment threshold values may be one or at leasttwo. If the number of adjustment threshold values is one, the adjustmentthreshold value may be directly selected. If the number of adjustmentthreshold values is at least two, one may be selected from the at leasttwo adjustment threshold values.

In an embodiment of the present invention, the number of presetadjustment threshold values is at least two, and the number ofadjustment threshold values selected according to the number of pulsesis at least two. Therefore, before 103, the method may further include:comparing the index value with the at least two adjustment thresholdvalues; if the index value is smaller than a minimum adjustmentthreshold value of the at least two adjustment threshold values,selecting the minimum adjustment threshold value; if the index value isgreater than a maximum adjustment threshold value of the at least twoadjustment threshold values, selecting the maximum adjustment thresholdvalue; if the index value is within a range formed by two adjacentadjustment threshold values of the at least two adjustment thresholdvalues, selecting the smaller adjustment threshold value of the twoadjacent adjustment threshold values.

For example, in an embodiment of the present invention, the number ofadjustment threshold values is one, and the adjustment threshold valueset for 6 pulses on a track is 547328.

Specifically, the selection of an adjustment threshold value may bedetermined by combining an occurrence probability and the number of bitsthat may be saved. In a codebook space, the smaller the selectedadjustment threshold value is, the more bits are saved, the lower theprobability that bits can be saved.

103: Judge whether the index value is smaller than the adjustmentthreshold value; if the index value is smaller than the adjustmentthreshold value, the process proceeds to 104; if the index value is notsmaller than the adjustment threshold value, the process proceeds to105.

Specifically, compare the index value with the adjustment thresholdvalue to judge whether the index value is smaller than the adjustmentthreshold value.

104: Adopt the first number of encoding bits to encode the index value;the entire process is completed.

The first number is a positive integer.

105: Add an offset value to the index value.

In an embodiment of the present invention, the offset value is greaterthan or equal to the adjustment threshold value.

106: Adopt the second number of encoding bits to encode the index valueplus the offset value; the entire process is completed.

The second number is also a positive integer, where the second number isgreater than the first number.

In an embodiment of the present invention, the second number may be avalue obtained by rounding up a theoretical value of the encoding bitsrequired to encode all pulses on a track. For example, when 6 pulsesexist on a track, 20.5637 encoding bits are required theoretically forencoding. Round up 20.5637 to obtain 21. That is, the second number maybe 21. In an embodiment of the present invention, the relationshipbetween the second number and the theoretical value of encoding bitsrequired to encode the various number of pulses on a track is as shownin Table 1.

TABLE 1 Number of Pulses on Theoretical Value a Same Track of EncodingBits Second Number 1 5 5 2 9 9 3 12.4179 13 4 15.4263 16 5 18.2110 19 620.5637 21

Certainly, obtaining the second number by rounding up the theoreticalvalue of encoding bits required to encode all pulses on a track is onlyan embodiment of the present invention, the second number may be greaterthan or smaller than the value obtained by rounding up the theoreticalvalue. The value of the second number is not limited to the embodimentsof the present invention.

It can be seen from the foregoing that, the embodiment may use thenumber of encoding bits smaller than the second number to encode theindex value if the index value is smaller than the adjustment thresholdvalue. That is, the second number of encoding bits does not need to beused to encode the index value smaller than the adjustment thresholdvalue. In this way, the encoding bits are saved, and the encodingefficiency is improved.

Take an example that 6 pulses exist on a track to describe a secondembodiment of the method for pulse encoding provided in an embodiment ofthe present invention. The number of encoding bits required to encode 6pulses on a track is 21, that is, 21 bits. 21 bits can indicate a rangefrom 0 to 2^21−1, and an index of 6 pulses ranges from 0 to 1549823.Therefore, a remaining space including 547328 numerical values existwithin the range from 1549824 to 2^21−1.

Calculate an index value index, and then compare the index with anadjustment threshold value THR. In this embodiment, only one THR is setand the THR may be 547328.

If the index is smaller than 547328, directly use the first number ofencoding bits to encode the index. In this embodiment, the first numberis 20.

If the index is greater than or equal to 547328, add 547328 to theindex, and use the second number of encoding bits to encode the indexplus 547328. In this embodiment, the second number is 21.

Specifically, when the index<THR, index=index, indicating thatindexε[0,THR−1], and 20 encoding bits are required to encode the index.

When 547328≦index<(2²¹−1549823), index=index+547328, indicating thatindexε[2*THR,2²¹−1], and 21 encoding bits are required to encode the newindex. Moreover, the most significant 20 bits of the index does notoverlap with [0, THR−1] because index/2ε[THR,2²⁰−1]. Therefore, theuniqueness of coding after the index value is encoded may be ensured.

In another embodiment of the present invention, only one THR is set, andthe THR may be 547325. If the index is smaller than 547325, directly usethe first number of encoding bits to encode the index. In thisembodiment, the first number is 20. If the index is greater than orequal to 547325, add an offset value to the index, and use the secondnumber of encoding bits to encode the index plus the offset value, wherethe range of the offset value is [547325,547328]. In this embodiment,the second number is 21.

FIG. 2 is a schematic diagram of index encoding, where 6 pulses exist ona track and the adjustment threshold value is 547328.

21 bits are required to encode 6 pulses on a track. 21 bits may indicatea range of [0, 2²¹−1], the range of a codebook space 201 correspondingto the index for encoding the 6 pulses is [0, 1549823], and the range ofa remaining space 202 is [1549824, 2²¹−1]. The adjustment thresholdvalue is 547328. Therefore, after the remaining space 202 is insertedafter 547327, the codebook space 201 is divided into two parts, that is,203 and 204, where the range of 203 is [0, 547327]. The original rangeof 204 is [547328, 1549823]. However, after the remaining space 202 isinserted, 204 reaches the end of the range of 21 bits, and thecorresponding range becomes [1094656, 2²¹−1]. At this time, 20 bits maybe used to encode the index values within the corresponding range of203, and 21 bits may be used to encode the index values within theoriginal range of 204 plus 547328.

In the method for pulse encoding provided in the embodiment of thepresent invention, the adjustment threshold value may be set within thecodebook space where the index value is located, and then the remainingspace is inserted after the adjustment threshold value. The remainingspace is a remaining part of the value space corresponding to the numberof encoding bits obtained by rounding up the theoretical value ofencoding bits required to encode all pulses on a track minus thecodebook space.

If the number of adjustment threshold values is at least two, the stepsfor inserting the remaining space after the adjustment threshold valuesmay specifically include: dividing the remaining space intosub-remaining spaces, where the number of sub-remaining spaces issmaller than or equal to the number of the adjustment threshold values;and inserting the sub-remaining spaces respectively after the adjustmentthreshold values, where the number of the adjustment threshold values isthe same as the number of the sub-remaining spaces.

In an embodiment of the present invention, the remaining space may bedivided into sub-remaining spaces, where the number of the sub-remainingspaces is the same as the number of the adjustment threshold values. Inanother embodiment of the present invention, the remaining space may bedivided into sub-remaining spaces on average. That is, the size of eachsub-remaining space is the same.

FIG. 3 is a schematic diagram of a remaining space adjustment, anddescribes how a remaining space is adjusted according to an embodimentof the present invention. A part 301 is a remaining codebook space, anda part 303 and a part 304 is a used codebook space. m−1 adjustmentthresholds are set for the part 303. Therefore, the part 303 is dividedinto m codebooks 305. Specifically, first divide the remaining codebookspace 301 into m sub-remaining spaces 302 on average, and then insert asub-remaining codebook space 302 between every two adjacent codebooks305. In this embodiment, the adjustment threshold value may be set as astart value of the used codebook space 304.

An index value of a pulse indicates a location and symbol of the pulseon a track. Therefore, writing the index value of the pulse into amultiplexed encoding code stream at an encoder end is writing thelocation and symbol of the pulse on the track into the encoding codestream. In this way, after demultiplexing the encoding code stream, thedecoder end may obtain the index value of the pulse, thus the locationand symbol of the pulse on the track are obtained.

A method for pulse decoding provided in an embodiment of the presentinvention is described in the following. FIG. 4 describes a process ofthe method for pulse decoding, where the method includes:

401: Demultiplex an encoding code stream and extract the first number ofencoding bits from the demultiplexed encoding code stream.

The first number is a positive integer. Specifically, extract the firstnumber of encoding bits from a location where an index value should bestored from the demultiplexed encoding code stream; when the firstnumber of encoding bits is adopted at an encoder end to encode the indexvalue, the index value may be decoded and obtained by using theextracted first number of encoding bits; when the number of encodingbits greater than the first number are adopted at the encoder end toencode the index value, only part of the index value can be decoded andobtained by using the extracted first number of encoding bits.

A decoder end does not know whether the first number of encoding bits orthe second number of encoding bits are adopted to encode the index valueat the encoder end. The index value corresponding to the first number ofencoding bits is definitely smaller than an adjustment threshold value.Therefore, assume that the first number of encoding bits is adopted atthe encoder end to encode the index value, extract the first number ofencoding bits from the location where the index value is located fromthe encoding code stream, and decode the first number of encoding bits.

402: Judge whether a decoded value of the first number of encoding bitsis smaller than the adjustment threshold value; if the decoded value ofthe first number of encoding bits is smaller than the adjustmentthreshold value, the process proceeds to 403; if the decoded value ofthe first number of encoding bits is not smaller than the adjustmentthreshold value, the process proceeds to 404.

403: Output the decoded value of the first number of encoding bits; theprocess is completed.

When the decoded value of the first number of encoding bits is smallerthan the adjustment threshold value, it indicates that the first numberof encoding bits is adopted at the encoder end to encode the index valueof the pulse. Therefore, the decoded value of the first number ofencoding bits is the index value.

404: Decode the second number of encoding bits, where the second numberof encoding bits is extracted from the code stream, and output a decodevalue of the second number of encoding bits; the process is completed.

If the decoded value of the first number of encoding bits is greaterthan or equal to the adjustment threshold value, it indicates that thesecond number of encoding bits is adopted at the encoder end to encodethe index value. Therefore, decode the second number of encoding bits,where the second number of encoding bits is extracted from the codestream, and output the decoded value of the second number of encodingbits. The decoded value of the second number of encoding bits is theindex value.

The second number is a positive integer, where the second number isgreater than the first number.

In an embodiment of the present invention, the step of decoding thesecond number of encoding bits, where the second number of the encodingbits is extracted from the code stream, may specifically include:extracting the second number of encoding bits from the code stream fordecoding. That is, including the first number of encoding bits, wherethe first number of encoding bits is extracted in step 401, the firstnumber and the second number of encoding bits are extracted totally. Inanother embodiment of the present invention, the step of decoding thesecond number of encoding bits, where the second number of the encodingbits is extracted from the code stream, may specifically include:extracting encoding bits from the code stream, where a sum of the numberof the encoding bits and the first number is equal to the second number,that is, including the first number of encoding bits, where the firstnumber of encoding bits is extracted in step 401, only the second numberof encoding bits needs to be extracted totally, and the decoding speedis increased; obtaining an intermediate value by adding a referencevalue to the decoded value of the first number of encoding bits and thenadding the decoded value of the encoding bits; obtaining the decodedvalue of the second number of encoding bits by subtracting an offsetvalue from the intermediate value. The offset value is greater than orequal to the adjustment threshold value.

The reference value is corresponding to the extracted number of encodingbits. Assume that the reference value is a, the decoded value of thefirst number of encoding bits is b, and the extracted number of encodingbits is c, then a=b (2^(c)−1).

It can be seen from the foregoing that, according to this embodiment,the first number of encoding bits may be decoded, so that the encoderend may use the first number of encoding bits to encode the index valuewhen the index value is smaller than the adjustment threshold value.That is, the second number of encoding bits does not need to be used toencode the index value smaller than the adjustment threshold value atthe encoder end. In this way, the encoding bits are saved, and theencoding efficiency is improved.

A device for pulse encoding provided in an embodiment of the presentinvention is described in the following. FIG. 5 describes a structure ofa first embodiment of the device for pulse encoding, where the deviceincludes:

a calculating unit 501, configured to calculate an index value of aninput pulse;

a selection unit 502, configured to select an adjustment threshold valueaccording to the number of pulses; and

an encoding unit 503, configured to adopt the first number of encodingbits to encode the index value if the index value calculated andobtained by the calculating unit 501 is smaller than the adjustmentthreshold value selected by the selection unit 502, and adopt the secondnumber of encoding bits to encode the index value plus an offset valueif the index value calculated and obtained by the calculating unit 501is greater than or equal to the adjustment threshold value selected bythe selection unit 502, where the first number is smaller than thesecond number, the first number and the second number are both positiveintegers, and the offset value is greater than or equal to theadjustment threshold value.

It can be seen from the foregoing that, the device for pulse encodingaccording to this embodiment may use the first number of encoding bitsto encode the index value if the index value is smaller than theadjustment threshold value. That is, the second number of encoding bitsdoes not need to be used to encode the index value smaller than theadjustment threshold value. In this way, the encoding bits are saved,and the encoding efficiency is improved.

FIG. 6 describes a structure of a second embodiment of the device forpulse encoding provided in an embodiment of the present invention, wherethe device includes:

a calculating unit 601, configured to calculate an index value of aninput pulse;

a selection unit 602, configured to select an adjustment threshold valueaccording to the number of pulses;

an encoding unit 603, configured to adopt the first number of encodingbits to encode the index value if the index value calculated andobtained by the calculating unit 601 is smaller than the adjustmentthreshold value selected by the selection unit 602, and adopt the secondnumber of encoding bits to encode the index value plus an offset valueif the index value calculated and obtained by the calculating unit 601is greater than or equal to the adjustment threshold value selected bythe selection unit 602, where the first number is smaller than thesecond number, the first number and the second number are both positiveintegers, and the offset value is greater than or equal to theadjustment threshold value;

a setting unit 604, configured to set an adjustment threshold within acodebook space where the index value calculated and obtained by thecalculating unit 601 is located; and

an insertion unit 605, configured to insert a remaining space after theadjustment threshold set by the setting unit 604, where the remainingspace is a remaining part of a value space corresponding to the numberof encoding bits obtained by rounding up a theoretical value of encodingbits required to encode all pulses on a track minus a codebook space.

In an embodiment of the present invention, the insertion unit 605 mayinclude: a dividing unit 6051, configured to divide the remaining spaceinto sub-remaining spaces, where the number of sub-remaining spaces issmaller than or equal to the number of adjustment threshold values; anda space insertion unit 6052, configured to respectively insert thesub-remaining spaces after the adjustment thresholds, where the numberof the adjustment thresholds is the same as the number of thesub-remaining spaces.

It can be seen from the foregoing that, the device for pulse encodingaccording to this embodiment may use the first number of encoding bitsto encode the index value if the index value is smaller than theadjustment threshold value. That is, the second number of encoding bitsdoes not need to be used to encode the index value smaller than theadjustment threshold value. In this way, the encoding bits are saved,and the encoding efficiency is improved.

A device for pulse decoding provided in an embodiment of the presentinvention is introduced below. FIG. 7 describes a structure of a firstembodiment of the device for pulse decoding, where the device includes:

an extraction unit 701, configured to demultiplex an encoding codestream and extract the first number of encoding bits from thedemultiplexed encoding code stream;

a decoding unit 702, configured to decode the first number of encodingbits, where the first number of encoding bits is extracted by theextraction unit 701, and if a decoded value of the first number ofencoding bits is greater than or equal to an adjustment threshold value,decode the second number of encoding bits, where the second number ofencoding bits is extracted from the code stream; and

an output unit 703, configured to output the decoded value of the firstnumber of encoding bits if the decoded value of the first number ofencoding bits, where the first number of encoding bits is decoded by thedecoding unit 702, is smaller than the adjustment threshold value, andoutput a decoded value of the second number of encoding bits if thedecoded value of the first number of encoding bits, where the firstnumber of encoding bits is decoded by the decoding unit 702, is notsmaller than the adjustment threshold value, where the first number issmaller than the second number, and the first number and the secondnumber are both positive integers.

It can be seen from the foregoing that, the device for pulse decodingaccording to this embodiment may decode the first number of encodingbits, so that the encoder end may use the first number of encoding bitsto encode the index value if the index value is smaller than theadjustment threshold value. That is, the second number of encoding bitsdoes not need to be used to encode the index value smaller than theadjustment threshold value at the encoder end. In this way, the encodingbits are saved, and the encoding efficiency is improved.

FIG. 8 describes a structure of a second embodiment of the device forpulse decoding, where the device includes:

an extraction unit 801, configured to extract the first number ofencoding bits from an encoding code stream; if a decoded value of thefirst number of encoding bits is greater than or equal to an adjustmentthreshold value, extract encoding bits from the code stream, where a sumof the number of the encoding bits and the first number is equal to asecond number; the first number is smaller than the second number, andthe first number and the second number are both positive integers; and

a decoding unit 802, configured to decode the first number of encodingbits, where the first number of encoding bits is extracted by theextraction unit 801, and if the decoded value of the first number ofencoding bits is greater than or equal to the adjustment thresholdvalue, decode the second number of encoding bits, where the secondnumber of encoding bits is extracted from the code stream.

In an embodiment of the present invention, the decoding unit 802 mayinclude: a calculating unit 8021, configured to obtain an intermediatevalue by adding a reference value to the decoded value of the firstnumber of encoding bits and then adding the decoded value of theextracted encoding bits; and an adjustment decoding unit 8022,configured to obtain a decoded value of the second number of encodingbits by subtracting an offset value from the intermediate valuecalculated by the calculating unit 8021, where the offset value isgreater than or equal to the adjustment threshold value.

An output unit 803 is configured to output the decoded value of thefirst number of encoding bits if the decoded value of the first numberof encoding bits decoded by the decoding unit 802 is smaller than theadjustment threshold value, and output the decoded value of the secondnumber of encoding bits if the decoded value of the first number ofencoding bits decoded by the decoding unit 802 is not smaller than theadjustment threshold value.

It can be seen from the foregoing that, the device for pulse decodingaccording to this embodiment may decode the first number of encodingbits, so that an encoder end may use the first number of encoding bitsto encode the index value if the index value is smaller than theadjustment threshold value. That is, the second number of encoding bitsdoes not need to be used to encode the index value smaller than theadjustment threshold value at the encoder end. In this way, the encodingbits are saved, and the encoding efficiency is improved.

To assess the performance of the embodiments of the present invention,the inventor collects statistics about the probabilities of differentpulse locations if 6 pulses exist on a track, and the result as shown inTable 2 is obtained. During the statistics, the adjustment thresholdvalue is 547328.

TABLE 2 Number of Bits Originally Required Number of Start Required bythe Pulse Value of Occurrence Encoding Number of Present LocationsEncoding Probability Range Bits Invention 6 0x00000 56.3961% [0, 21 bit20 bit 5 0x07d200 36.4399% HR-1] 4 0x127c00 6.1064% [THR, 21 bit 21 bit3 0x16ed80 0.7577% 2²¹ − 1] 2 0x179c80 0.1216% 1 0x17a5e0 0.1783%

It can be seen from Table 2 that the probability of 6 different pulselocations on a track is the highest, and the probability of differentpulses locations on a track is the second highest. Moreover, in all thecases of 6 pulse locations and some cases of 5 pulse locations, only 20encoding bits are required for encoding, which saves 1 bit compared withthe 21 encoding bits required by the prior art. It can be seen fromTable 2 that, in the mode of 6 pulses on a track, 1 bit can be saved inapproximately over 60% cases.

The inventor also collects statistics about the cases in which 1 to 6pulses exist on a track, and the statistical result is as shown in Table3.

TABLE 3 Number of Required Encoding Bits Number of Pulses TheoreticalPresent on a Same Track Value Prior art Invention 1 5 5 5 2 9 9 9 312.4179 13 12 or 13 4 15.4263 16 15 or 16 5 18.1210 19 18 or 19 620.5637 21 20 or 21

It can be seen from Table 3 that, according to the embodiments of thepresent invention, in some cases of 3, 4, 5, or 6 pulses on a track, oneencoding bit can be saved, and therefore, the purpose of improving theencoding efficiency is achieved.

Persons of ordinary skill in the art may understand that all or part ofthe steps of the method according to the foregoing embodiments may beimplemented by a program instructing relevant hardware. The program maybe stored in a computer readable storage medium. When the program isexecuted, the steps of each method according to the foregoingembodiments may be performed. The storage medium may be a magnetic disk,an optical disk, a Read-Only Memory (ROM), or a Random Access Memory(RAM).

The method and device for pulse encoding and the method and device forpulse decoding provided in the embodiments of the present invention aredescribed in detail above. The description about the precedingembodiments is merely provided for ease of understanding of the methodand ideas of the present invention. Persons of ordinary skill in the artmay make variations and modifications to the present invention in termsof the specific implementations and application scopes according to theideas of the present invention. Therefore, the specification shall notbe construed as limitations to the present invention.

What is claimed is:
 1. A method for pulse encoding, the methodcomprising: calculating an index value of an input pulse; selecting afirst adjustment threshold value according to the number of pulses;comparing the index value of the pulse with the first adjustmentthreshold value; if the index value is smaller than the first adjustmentthreshold value, adopting the first number of encoding bits to encodethe index value, if the index value is not smaller than the firstadjustment threshold value, adopting the second number of encoding bitsto encode the index value plus an offset value, wherein the first numberis smaller than the second number, the first number and the secondnumber are both positive integers, and the offset value is greater thanor equal to the first adjustment threshold value; and wherein selectinga first adjustment threshold value according to the number of pulsescomprises: determining at least two adjustment threshold valuesaccording to the number of pulses, comparing the index value with the atleast two adjustment threshold values, and if the index value is smallerthan a minimum adjustment threshold value of the at least two adjustmentthreshold values, selecting the minimum adjustment threshold value asthe first adjustment threshold value, or if the index value is greaterthan a maximum adjustment threshold value of the at least two adjustmentthreshold values, selecting the maximum adjustment threshold value asthe first adjustment threshold value, or if the index value is within arange formed by two adjacent adjustment threshold values of the at leasttwo adjustment threshold values, selecting the smaller adjustmentthreshold value of the two adjacent adjustment threshold values as thefirst adjustment threshold value.
 2. The method for pulse encodingaccording to claim 1, wherein the second number is a value obtained byrounding up a theoretical value of encoding bits required to encode thepulse.
 3. The method for pulse encoding according to claim 2, whereinbefore calculating the index value of the input pulse, the methodfurther comprises: setting a second adjustment threshold value within acodebook space wherein the index value is located; and inserting aremaining space after the second adjustment threshold value, wherein theremaining space is a remaining part of a value range corresponding tothe number of encoding bits obtained by rounding up the theoreticalvalue minus the codebook space.
 4. The method for pulse encodingaccording to claim 3, wherein the second adjustment threshold value issmaller than or equal to the number of numerical values in the remainingspace.
 5. The method for pulse encoding according to claim 3, whereininserting the remaining space after the second adjustment thresholdvalues comprises: dividing the remaining space into sub-remainingspaces, wherein the number of sub-remaining spaces is smaller than orequal to the number of the second adjustment threshold values; andinserting the sub-remaining spaces after the second adjustment thresholdvalues, wherein the number of the second adjustment threshold values isthe same as the number of the sub-remaining spaces.
 6. The method forpulse encoding according to claim 5, wherein dividing the remainingspace into at least two sub-remaining spaces comprises: dividing theremaining space into sub-remaining spaces on average.
 7. A method forpulse decoding, the method comprising: demultiplexing an encoding codestream and extracting the first number of encoding bits from thedemultiplexed encoding code stream; if a decoded value of the firstnumber of encoding bits is smaller than an adjustment threshold value,outputting the decoded value of the first number of encoding bits; andif the decoded value of the first number of encoding bits is greaterthan or equal to the adjustment threshold value, extracting encodingbits from the code stream, wherein a sum of the number of extractedencoding bits and the first number is equal to the second number;obtaining an intermediate value by adding a reference value to thedecoded value of the first number of encoding bits and then adding thedecoded value of the extracted encoding bits; and obtaining the decodedvalue of the second number of encoding bits by subtracting an offsetvalue from the intermediate value, wherein the offset value is greaterthan or equal to the adjustment threshold value, and outputting adecoded value of the second number of encoding bits, wherein the firstnumber is smaller than the second number, and the first number and thesecond number are both positive integers.
 8. A device for pulseencoding, the device comprising: a calculating unit, configured tocalculate an index value of an input pulse; a selection unit, configuredto select a first adjustment threshold value according to the number ofpulses; an encoding unit, configured to adopt the first number ofencoding bits to encode the index value if the index value calculatedand obtained by the calculating unit is smaller than the firstadjustment threshold value selected by the selection unit, and adopt thesecond number of encoding bits to encode the index value plus an offsetvalue if the index value calculated and obtained by the calculating unitis greater than or equal to the first adjustment threshold valueselected by the selection unit, wherein the first number is smaller thanthe second number, the first number and the second number are bothpositive integers, and the offset value is greater than or equal to thefirst adjustment threshold value; wherein the selection unit is furtherconfigured to: determine at least two adjustment threshold valuesaccording to the number of pulses, compare the index value with the atleast two adjustment threshold values, and if the index value is smallerthan a minimum adjustment threshold value of the at least two adjustmentthreshold values, select the minimum adjustment threshold value as thefirst adjustment threshold value; or if the index value is greater thana maximum adjustment threshold value of the at least two adjustmentthreshold values, select the maximum adjustment threshold value as thefirst adjustment threshold value; or if the index value is within arange formed by two adjacent adjustment threshold values of the at leasttwo adjustment threshold values, select the smaller adjustment thresholdvalue of the two adjacent adjustment threshold values as the firstadjustment threshold value.
 9. The device for pulse encoding accordingto claim 8, further comprising: a setting unit, configured to set asecond adjustment threshold within a codebook space wherein the indexvalue calculated and obtained by the calculating unit is located; and aninsertion unit, configured to insert a remaining space after the secondadjustment threshold set by the setting unit, wherein the remainingspace is a remaining part of a value range corresponding to the numberof encoding bits obtained by rounding up a theoretical value of encodingbits required to encode the pulse minus the codebook space.
 10. Thedevice for pulse encoding according to claim 9, wherein the insertionunit comprises: a dividing unit, configured to divide the remainingspace into sub-remaining spaces, wherein the number of sub-remainingspaces is smaller than or equal to the number of the second adjustmentthreshold values; and a space insertion unit, configured to respectivelyinsert the sub-remaining spaces after the second adjustment thresholdvalues, wherein the number of the second adjustment threshold values isthe same as the number of the sub-remaining spaces.
 11. A device forpulse decoding, the device comprising: an extraction unit, configured todemultiplex an encoding code stream and extract the first number ofencoding bits from the demultiplexed encoding code stream, and furtherconfigured to extract encoding bits from the code stream if the decodedvalue of the first number of encoding bits is greater than theadjustment threshold value, wherein a sum of the number of the extractedencoding bits and the first number is equal to the second number; adecoding unit, configured to decode the first number of encoding bits,wherein the first number of encoding bits is extracted by the extractionunit, and if a decoded value of the first number of encoding bits isgreater than or equal to an adjustment threshold value, decode thesecond number of encoding bits, wherein the second number of encodingbits is extracted from the encoding code stream, the decoding unitcomprising: a calculating unit, configured to obtain an intermediatevalue by adding a reference value to the decoded value of the firstencoding bits and then adding the decoded value of the extractedencoding bits, and an adjustment decoding unit, configured to obtain thedecoded value of the second number of encoding bits by subtracting anoffset value from the intermediate value, wherein the offset value isgreater than or equal to the adjustment threshold value; and an outputunit, configured to output the decoded value of the first number ofencoding bits if the decoded value of the first number of encoding bitsdecoded by the decoding unit is smaller than the adjustment thresholdvalue, and output a decoded value of the second number of encoding bitsif the decoded value of the first number of encoding bits decoded by thedecoding unit is not smaller than the adjustment threshold value,wherein the first number is smaller than the second number, and thefirst number and the second number are both positive integers.